package designPattern.visitorPattern.visitor;

/**
 * ShoppingCarVistor
 *
 * @author nanxin.chen
 * @date 2015/8/29
 */
public class VisitorNormal implements IShoppingVisitor {

    @Override
    public double visit(Fruit fruit) {
        String info =  String.format("name:%s, num:%s, price:%s, total:", fruit.getName(), fruit.getNum(), fruit.getPrice());
        System.out.println(info + fruit.getPrice() * fruit.getNum());
        return fruit.getPrice() * fruit.getNum();
    }
    @Override
    public double visit(Book book) {
        String info =  String.format("name:%s, num:%s, price:%s, ISBN:%s, total:", book.getName(), book.getNum(), book.getPrice(), book.getISBN());
        System.out.println(info + book.getPrice() * book.getNum());
        return book.getPrice() * book.getNum();
    }
}
